package com.app.util.common;

public class StringUtil {

	/**
	 * //生成6位随机数
	 */
	public static String randomCode() {
	    int i = (int) ((Math.random() * 9 + 1) * 100000);
	    
	    return String.valueOf(i);
	}
	
	/**
	 * 返回两位的数字
	 * @param num
	 * @return
	 */
	public static String getStrNum(int num){
		String value= num+"";
		if(num<10){
			value = "0"+num;
		} 
		
		return value;
	}
	
	/**
	 * 获取有效字符串，去除首位逗号
	 * @param str    
	 * @return
	 */
	public static String getStr(String str){ 
		
		String result = str;
		if(!"".equals(result)){
			String strFirstChar = result.substring(0, 1);
			String strLastChar = result.substring(result.length()-1, result.length());
			if(strFirstChar.equals(",")){
				result = result.substring(1);
			}
	        if(strLastChar.equals(",")){
	        	result = result.substring(0, result.length()-1);
			} 
		}  
		
		return result;
	} 
}
